1. Virtual Environment Dependencies
To ensure the agent runs successfully in an isolated Python virtual environment (.venv), the following dependencies must be installed. This prevents relying on global system packages and guarantees that the ADK server processes have access to the correct libraries.
Terminal Commands:
# Ensure your virtual environment is active
source .venv/bin/activate
# Install required packages
pip install litellm
pip install numpy
pip install orjson
Package Breakdown:
litellm: The core wrapper library that translates standard LLM requests into formats compatible with 100+ different providers.numpy: Required specifically for yourroll_die()tool function to generate random integers.orjson: A high-performance JSON parsing library required under the hood by LiteLLM and the OpenAI API client to handle connection schemas.
2. Agent Configuration Code
The original script was hardcoded to use model='gemini-2.5-flash'. To route requests to a local proxy, we updated the Python code to utilize the LiteLlm model wrapper class.
Key Modifications:
- Imported LiteLlm: Added
from google.adk.models.lite_llm import LiteLlmto the top of the file. - Nested Configuration: Shifted the
api_baseandapi_keyvariables inside theLiteLlm(...)instantiation block so they are correctly parsed as model configurations, rather than invalid agent arguments. - Provider Prefix: Appended
openai/to the model name (resulting inopenai/production-deep-context) to explicitly instruct LiteLLM to use the OpenAI API translation schema when talking to your proxy on port 4000.
Final agent.py Code:
from google.adk.agents.llm_agent import Agent
from google.adk.models.lite_llm import LiteLlm
import numpy as np
def roll_die() -> int:
"""Return the value of a rolled dice"""
value = np.random.randint(1, 7)
return {"status": "success", "value": value}
root_agent = Agent(
model=LiteLlm(
model="openai/production-deep-context",
api_base="http://10.11.11.200:4000/v1",
api_key="sk-8n9_TCUmCFayrUIXK5z_ZA"
),
name="dice_agent",
description=(
"hello world agent that can roll a dice of 6 sides"
),
instruction="""
You roll dice and tell the outcome of the dice.
""",
tools=[
roll_die,
],
)